<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <style>
        [v-cloak]{
            display: none;
        }
    </style>
</head>
<body>
<div id="app" v-cloak>
    <h2>{{fullname}}</h2>
    <button v-on:click="setFullname">设置fullname</button>
</div>
<script src="https://unpkg.com/vue@3"></script>
<script>
    const app=Vue.createApp({
        data(){
            return{
                firstName:'kobe',
                lastName:'bryant',
            }
        },
        computed:{
            fullname:{
                get:function(){
                    return this.firstName+" "+this.lastName
                },
                set:function(val){
                    let names=val.split(" ")
                    this.firstName=names[0]
                    this.lastName=names[1]
                }
            }
        },
        methods:{
            setFullname(){
                this.fullname='ding+ jie'
            }
        }
    })
    app.mount("#app")
</script>
</body>
</html>